#!/bin/sh

judge_if_exists_logdir_mkdir()
{
dir=$1
if [ ! -d $dir ];
then
#  errlog "${dir}:No directory."
  mkdir -p $dir  
fi

}

judge_if_exists_dir_mkdir()
{
dir=$1
if [ ! -d $dir ];
then
  errlog "${dir}:No directory."
  mkdir -pv $dir 2>&1 | writelogfile
else
  infolog "$dir check sucessful"
fi

}

judge_if_exists_dir_exit()
{
dir=$1
if [ ! -d $dir ];
then
  errlog "${dir}:No directory."
  exit 1

else
  infolog "$dir check sucessful"
fi

}

judge_if_exists_file_return()
{
file=$1
if [ ! -f $file ];
then
  errlog "${file}:No Such file."
  return 1

else
  infolog "$file check sucessful"
fi

}

judge_if_exists_file_exit()
{
file=$1
if [ ! -f $file ];
then
  errlog "${file}:No Such file."
  exit 1

else
  infolog "$file check sucessful"
fi

}


judge_ret_code()
{
ret_code=$1
if [ ${ret_code} -eq 0 ];
then

  infolog "ret_code: ${ret_code}"
else
  errlog "ret_code: ${ret_code}"
  return 1
fi


}

judge_ret_code_exit()
{
ret_code=$1
if [ ${ret_code} -eq 0 ];
then

  infolog "ret_code: ${ret_code}"
else
  errlog "ret_code: ${ret_code}"
  exit

fi


}


